package com.eapi.project.service.impl;
import java.util.Date;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.eapi.project.exception.BusinessException;
import com.eapi.project.common.ErrorCode;
import com.eapi.project.mapper.CommentMapper;
import com.eapi.project.model.entity.Comment;
import com.eapi.project.service.CommentService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
* @author lenovo
* @description 针对表【comment(用户接口评论表)】的数据库操作Service实现
* @createDate 2024-04-02 21:12:11
*/
@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment>
    implements CommentService {
    @Override
    public void validComment(Comment comment, boolean add) {
     Long id = comment.getId();
     Long userId = comment.getUserId();
     String username = comment.getUserName();
     Long interfaceinfoId = comment.getInterfaceInfoId();
     String interfaceInfoName = comment.getInterfaceInfoName();
     String context = comment.getContext();
     Long likes = comment.getLikes();
     Date createtime = comment.getCreatetime();
     Date updatetime = comment.getUpdatetime();
     Integer isdelete = comment.getIsdelete();
        if (comment == null) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        if (add) {
            if (interfaceinfoId <= 0 || userId<= 0 ){
                throw new BusinessException(ErrorCode.PARAMS_ERROR,"接口或用户不存在");
            }
        }
        if (StringUtils.isBlank(context)) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR, "评论内容不能为空");
        }

    }
}




